package com.paas.service.modules.sso.cas.client.shiro;

import java.util.HashSet;
import java.util.Set;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.cas.CasRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.stereotype.Service;

@Service("myShiroRealm")
public class MyCasRealm extends CasRealm {
//	public MyCasRealm() {
//		super();
//	}

	// 获取授权信息
	@Override
	protected AuthorizationInfo doGetAuthorizationInfo(
			PrincipalCollection principals) {
		//ModularRealmAuthenticator
//		CentralAuthenticationServiceImpl
//		DefaultFilter
		System.out.println("===============================已经授权了添加授权信息");
		// ... 与前面 MyShiroRealm 相同
		Set<String> roleNames = new HashSet<String>();
		Set<String> permissions = new HashSet<String>();
		roleNames.add("admin");
		permissions.add("user.do?myjsp");
		permissions.add("login.do?main");
		permissions.add("login.do?logout");
		SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roleNames);
		info.setStringPermissions(permissions);
		return info;
	}
	

}